
import { getOpenId, getUserId, getUserPhone } from '../../userData/userData';
//获取用户openid
export function getUserOpenId() {
  return wx.cloud.callFunction({
    name: "common_getOPENID"
  })
}
//用户登录
export function userLogin() {
  return wx.cloud.callFunction({
    name: "user_login",
    data: {
      openid: getOpenId(),
      photo: "",
      username: "",
      type: "",
      phone: ""
    }
  })
}

//用户更新信息
export function userUpdateInfo(data) {
  const openid = getOpenId()
  const userId = getUserId()
  return wx.cloud.callFunction({
    name: "user_updateInfo",
    data: {
      openid: openid,
      user_id: userId,
      photo: "1",
      username: data.name,
      type: "1",
      phone: getUserPhone()

    }
  })
}
//获取手机号
export function getUserCloudPhone(e) {
  console.log(e)
  return wx.cloud.callFunction({
    name: "user_getPhone",
    data: {
      phone: wx.cloud.CloudID(e.detail.cloudID)
    }
  })
}